package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Return implements Ioperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入你要归还的书名：");
        Scanner scan = new Scanner(System.in);
        String bookName = scan.nextLine();

        int count = bookList.getCur();
        for (int i = 0; i < count; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(bookName)){
                if(book.isBorrowed() == true){
                    System.out.println("成功归还......");
                    book.setBorrowed(false);
                }else{
                    System.out.println("已被归还......");
                }
                return;
            }
        }
    }
}
